<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>提现</title>
    <link href="css/mui.css" rel="stylesheet"/>
    <link href="css/user.css" rel="stylesheet"/>
</head>
<body>
<div id="app" v-cloak>
    <header class="mui-bar mui-bar-nav header">
        <a href="user_list.html" class="mui-icon mui-icon-left-nav mui-pull-left"></a>
        <h2 class="mui-title">提现</h2>
        <a href="user_history.html" class="mui-icon mui-pull-right" style="margin-top: 6px;font-size: 14px;">明细</a>
    </header>

    <div class="mui-content" style="background: #f2f2f2;">
        <div class="userWithdrawal">

            <div class="userWithdrawalSec">
                <div class="userIndexList">
                    <ul class="mui-table-view">
                        <li class="mui-table-view-cell">
                            <a>
                                <span>可提金额</span>
                                <div class="fl_right">{{money ? money : "0.00"}}元</div>
                            </a>
                        </li>
                        <li class="mui-table-view-cell">
                            <a href="user_bank.html">
                                <span>提款银行</span>
                                <div class="fl_right" v-if="bkname=='' || bkname==null" :data-cardId="cardId">{{card ? card.bankName : "无绑定银行卡前往绑定"}}</div>
                                <div class="fl_right" v-else :data-cardId="cardId">{{ bkname }}</div>
                            </a>
                        </li>
                        <li class="mui-table-view-cell" style="font-size: 0.3rem;">
                            <span>
                                <span>提款金额</span>
                                <div class="fl_right">
                                    <div class="mtable_rightInput">
                                        <input type="number" name="" placeholder="输入金额"
                                                v-model="getMoney"
                                                onblur="this.placeholder='输入金额'"
                                                onfocus="this.placeholder=''"
                                                class="uil_input"><span>元</span>
                                    </div>
                                </div>
                            </span>
                        </li>
                    </ul>
                </div>
                <div class="userIndexTitle">
                    <h4>1.提现金额不得低于1元。</h4>
                    <h4>2.提现金额<=1000元，扣除1%手续费，1000元以上不收取手续费。</h4>
                    <h4>3.T+1到账，当日提现操作，次日银行卡到账，双休日或节假日到账时间顺延。</h4>
                </div>
            </div>

            <div class="userInfoSubmit"><a class="btn-red btn-bloak" @click="forward()">确认提现</a></div>

        </div>
    </div>
</div>
</body>

<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="js/mui.min.js"></script>
<script type="text/javascript" src="js/vue.js"></script>
<script type="text/javascript" src="js/rem.js"></script>
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript">
    'use strict'

    $(document).ready(function () {
		if(!sessionStorage.getItem("Authorization")){
			mui.alert('', '请先登录', function () {
				window.location.href = 'login.html'
			})
		}
        new Vue({
            el: '#app',
            data: {
                card: {},
                money: '',
                cardId:{},
                getMoney:'',
                bkname:''
            },
            mounted: function () {
                this.getReflect()
            },
            methods: {
                /**
                 *  获取提现银行卡和余额
                 */
                getReflect: function () {
                    let url = 'biz/api/getReflect',
                        that = this,
                        bkname = sessionStorage.getItem('bkname'),
                        bkid = sessionStorage.getItem('bkid'),

                    getReflectSuc = (data) => {
                            // console.log(data)

                        that.money = data.data.memBonus

                        if(bkid=='' || bkid==null){
                            that.card = data.data.jszcBankDTO
                            that.cardId = data.data.jszcBankDTO.id
                        } else {
                            that.bkname = bkname
                            that.cardId = bkid
                        }
                        
                    },

                    getReflectErr = (err) => {
                        console.log(err)
                    }

                    common.ajax(url, null, getReflectSuc, getReflectErr, 'GET')
                },

                // 提现
                forward:function(){
                    let that = this,
                        url = 'biz/api/forward?bankId='+that.cardId+'&amount='+that.getMoney,

                    forwardSuc = (data) => {
                        if(data.code==1000){
                            mui.alert( '提现申请已提交，预计24小时内到账', '', function(){ 
                                window.location = 'user_list.html'
                            })
                        } else if(data.code==1007) {
                            mui.alert( '请输入金额', '', function(){ })
                        } else {
                            mui.alert( '', data.msg, function(){ })
                        }
                    },

                    forwardErr = (err) => {
                        console.log(err)
                    }
                    if(that.getMoney=='' || that.getMoney==null){
                        mui.alert( '请输入金额', '', function(){ })
                        return false;
                    } else if(that.getMoney<1){
                        mui.alert( '最少提现1元', '', function(){ })
                        return false;
                    }
                    common.ajax(url, null, forwardSuc, forwardErr, 'GET')
                }
            }
        })

    })
</script>
</html>
